home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / arc42s.lbr / ARCDEL.MQC / arcdel.mac
Text File  |  1985-08-04  |  3KB  |  62 lines

  1. /*  ARC - Archive utility - ARCDEL
  2.  
  3. $define(tag,$$segment(@1,$$index(@1,=)+1))#
  4. $define(version,Version $tag(
  5. TED_VERSION DB =2.04), created on $tag(
  6. TED_DATE DB =04/17/85) at $tag(
  7. TED_TIME DB =11:30:48))#
  8. $undefine(tag)#
  9.     $version
  10.  
  11. (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  12.  
  13.     By:  Thom Henderson
  14.  
  15.     Description:
  16.          This file contains the routines used to delete entries
  17.          in an archive.
  18.  
  19.     Language:
  20.          Computer Innovations Optimizing C86
  21. */
  22. #include <stdio.h>
  23. #include "arc.h"
  24.  
  25. delarc(num,arg)                        /* remove files from archive */
  26. int num;                               /* number of arguments */
  27. char *arg[];                           /* pointers to arguments */
  28. {
  29.     struct heads hdr;                  /* header data */
  30.     int del;                           /* true to delete a file */
  31.     int n;                             /* index */
  32.  
  33.     if(!num)                           /* she must specify which */
  34.          abort("You must tell me which files to delete!");
  35.  
  36.     openarc(1);                        /* open archive for changes */
  37.  
  38.     while(readhdr(&hdr,bak))           /* while more entries in archive */
  39.     {    del = 0;                      /* reset delete flag */
  40.          for(n=0; n<num; n++)          /* for each template given */
  41.          {    if(match(hdr.name,arg[n]))
  42.               {    del = 1;            /* turn on delete flag */
  43.                    break;              /* stop looking */
  44.               }
  45.          }
  46.  
  47.          if(del)                       /* skip over unwanted files */
  48.          {    fseek(bak,hdr.size,1);
  49.               if(note)
  50.                    printf("Deleting file: %s\n",hdr.name);
  51.          }
  52.          else                          /* else copy over file data */
  53.          {    writehdr(&hdr,arc);      /* write out header and file */
  54.               filecopy(bak,arc,hdr.size);
  55.          }
  56.     }
  57.  
  58.     hdrver = 0;                        /* special end of archive type */
  59.     writehdr(&hdr,arc);                /* write out archive end marker */
  60.     closearc(1);                       /* close archive after changes */
  61. }
  62.